package com.google.code.sms.android.parser;

import android.content.Context;
import org.xmlpull.v1.XmlPullParser;

import java.io.Reader;

/**
 * @author Sindre Mehus
 */
public class ErrorParser extends AbstractParser {

    public ErrorParser(Context context) {
        super(context);
    }

    public void parse(Reader reader) throws Exception {

        init(reader);

        int eventType;
        do {
            eventType = nextParseEvent();
            if (eventType == XmlPullParser.START_TAG && "error".equals(getElementName())) {
                handleError();
            }
        } while (eventType != XmlPullParser.END_DOCUMENT);

        validate();
    }
}